Restore a shortcut in hot loop in _mime_hdr_field_list_search_by_string#13119
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restores a fast-path check in the MIME header field linear search hot loop to reduce unnecessary case-insensitive string comparisons and recover throughput regression seen on the 10.2.x branch.
Changes:
- Add a name-length equality check before calling
strcasecmp()in_mime_hdr_field_list_search_by_string().
|
What strcasecmp() is it calling and look at inlining the function? |
|
This The problem is that this trafficserver/lib/swoc/src/string_view_util.cc Lines 29 to 47 in a26a2d8 |
|
I introduced a new helper function, I found 3b0f0b7 did the same change in three places, so this PR restores the length check with There're so many other libswoc |
| For case-sensitive comparison, use @c std::string_view::operator==. | ||
| */ | ||
| inline bool | ||
| iequals(std::string_view lhs, std::string_view rhs) noexcept |
There was a problem hiding this comment.
Standard library doesn't have this, but boost has one. I followed the naming.
https://www.boost.org/doc/libs/latest/libs/beast/doc/html/beast/ref/boost__beast__iequals.html
There was a problem hiding this comment.
Does libswoc already have a compare like this?
There was a problem hiding this comment.
CaselessEqual is similar, but it's a functor on TextView (won't accept a plain std::string_view). IMO worth adding ts::iequals for simplicity and cleanness.
trafficserver/lib/swoc/include/swoc/TextView.h
Lines 963 to 970 in 4bba678
bneradt
left a comment
There was a problem hiding this comment.
Looks reasonable. Let's merge this in as is.
There's a lot of strcasecmp in our code. Should we more generally replace these?
|
I do agree with we should replace all |
@c-taylor noticed the 10.2.x branch has regression of throughput performance. It looks like several changes made it but the first big drop is introduced by
3b0f0b760387af0c4f6fdd40c4bc98f14dbf0c4d. The shortcut in the hot loop seems important.Below is comparison of 1 URL against 1 ET_NET thread performance.